#!/usr/bin/python
#-*- coding: utf-8 -*-

# CPBMI Python Homework 6-3
# Programmed by Seunghwan Kim

import hashlib
import glob

hash_sequences = [
    'a1ce8e1c43bc97259557379589e051af', 
    '3d4fe7a00bc6fb52a91685d038733d6f', 
    'be5d5d37542d75f93a87094459f76678',
    '56ab24c15b72a457069c5ea42fcfc640', 
    '22af645d1859cb5ca6da0c484f1f37ea', 
    '84cdc76cabf41bd7c961f6ab12f117d8'
]

passwd_list = dict()

file_list = glob.glob('wordfile/*')
file_list.append('passwd.txt')

for file in file_list:
    fp = open(file, "r")
    for line in fp.readlines():
        md5_object = hashlib.md5()
        md5_object.update(line.strip())
        passwd_list[md5_object.hexdigest()] = line
    fp.close()

for passwd in hash_sequences:
    print passwd_list[passwd]
